//
//  SOMhUCJLCFHomeServiceControllerYMHYGy.m
//  Jlcf_ios
//
//  Created by 邓伟浩 on 2019/4/12.
//  Copyright © 2019 ski. All rights reserved.
//

#import "SOMhUCJLCFHomeServiceControllerYMHYGy.h"
#import "IpxzlFJLCFHomeRequestPfjhYJ.h"

@interface SOMhUCJLCFHomeServiceControllerYMHYGy ()

@property (nonatomic, strong) UILabel *DrpOoTserviceTimeLabelJpcEbP;
@property (nonatomic, strong) UILabel *uSRgyWservicePhoneLabelqKiweC;

@property (nonatomic, strong) cwcQCAJLCFHomeServiceDataModelQnsgio *JityuBserviceModelPgophx;

@end

@implementation SOMhUCJLCFHomeServiceControllerYMHYGy

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUpUI];
    [self addNavigationBar];
    
    self.view.backgroundColor = QTZ_Gray237;
    
    [self loadData];
}

- (void)addNavigationBar
{
    [self.navigationBar removeFromSuperview];
    [super addNavigationBar];
    self.navigationBar.backgroundColor = [UIColor clearColor];
    self.navigationBar.title = @"客服中心";
    self.navigationBar.titleLabel.textColor = QTZ_White;
    self.navigationBar.titleLabel.font = FONT(15);
    [self.navigationBar setBottomBorderColor:[UIColor clearColor]];
    UIButton *backButton = [UIButton whiteBackBtnWithTarget:self action:@selector(clickback) forControlEvents:UIControlEventTouchUpInside];
    [backButton setTitleColor:QTZ_White forState:0];
    [self.navigationBar setLeftBarButton:backButton];
}

- (void)setUpUI {
    UIView *topView = [[UIView alloc] init];
    [self.view addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(self.view);
        make.height.mas_equalTo(FitRealValue(440));
    }];
    UIImageView *back = [[UIImageView alloc] init];
    [topView addSubview:back];
    back.image = [UIImage imageNamed:@"icon_home_serviceTopBack"];
    [back mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(topView);
    }];
    
    UILabel *edHyphtipsLabelTVYPVW = [[UILabel alloc] init];
    edHyphtipsLabelTVYPVW.text = @"在线客服";
    edHyphtipsLabelTVYPVW.font = FONT(15);
    edHyphtipsLabelTVYPVW.textColor = QTZ_White;
    edHyphtipsLabelTVYPVW.textAlignment = NSTextAlignmentCenter;
    [topView addSubview:edHyphtipsLabelTVYPVW];
    [edHyphtipsLabelTVYPVW mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(topView);
        make.top.mas_equalTo(topView.mas_top).offset(FitRealValue(180));
        make.centerX.mas_equalTo(topView);
    }];
    
    UILabel *DrpOoTserviceTimeLabelJpcEbP = [[UILabel alloc] init];
    [topView addSubview:DrpOoTserviceTimeLabelJpcEbP];
    DrpOoTserviceTimeLabelJpcEbP.text = @"人工客服时间：";
    DrpOoTserviceTimeLabelJpcEbP.textAlignment = NSTextAlignmentCenter;
    DrpOoTserviceTimeLabelJpcEbP.textColor = QTZ_White;
    DrpOoTserviceTimeLabelJpcEbP.font = FONT(14);
    [topView addSubview:DrpOoTserviceTimeLabelJpcEbP];
    [DrpOoTserviceTimeLabelJpcEbP mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(topView);
        make.left.right.mas_equalTo(topView);
        make.top.mas_equalTo(edHyphtipsLabelTVYPVW.mas_bottom).offset(FitRealValue(40));
    }];
    _DrpOoTserviceTimeLabelJpcEbP = DrpOoTserviceTimeLabelJpcEbP;
    
    UILabel *uSRgyWservicePhoneLabelqKiweC = [[UILabel alloc] init];
    [topView addSubview:uSRgyWservicePhoneLabelqKiweC];
    uSRgyWservicePhoneLabelqKiweC.text = @"客服电话号码：";
    uSRgyWservicePhoneLabelqKiweC.textAlignment = NSTextAlignmentCenter;
    uSRgyWservicePhoneLabelqKiweC.textColor = QTZ_White;
    uSRgyWservicePhoneLabelqKiweC.font = FONT(14);
    [topView addSubview:uSRgyWservicePhoneLabelqKiweC];
    [uSRgyWservicePhoneLabelqKiweC mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(topView);
        make.left.right.mas_equalTo(topView);
        make.top.mas_equalTo(DrpOoTserviceTimeLabelJpcEbP.mas_bottom).offset(FitRealValue(20));
    }];
    _uSRgyWservicePhoneLabelqKiweC = uSRgyWservicePhoneLabelqKiweC;
    
    UIView *bottomView = [[UIView alloc] init];
    [self.view addSubview:bottomView];
    bottomView.backgroundColor = QTZ_White;
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.view);
        make.top.mas_equalTo(topView.mas_bottom).offset(FitRealValue(20));
        make.height.mas_equalTo(FitRealValue(300));
    }];
    
    UILabel *NdgzxmdesLabelTTSqri = [[UILabel alloc] init];
    NdgzxmdesLabelTTSqri.text = @"任何疑问、建议投诉等，可通过客服电话客服咨询";
    NdgzxmdesLabelTTSqri.textAlignment = NSTextAlignmentCenter;
    NdgzxmdesLabelTTSqri.font = FONT(14);
    NdgzxmdesLabelTTSqri.textColor = QTZ_Gray118;
    [bottomView addSubview:NdgzxmdesLabelTTSqri];
    [NdgzxmdesLabelTTSqri mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(bottomView);
        make.left.right.mas_equalTo(bottomView);
        make.top.mas_equalTo(bottomView.mas_top).offset(FitRealValue(40));
    }];
    
    UIButton *callBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [bottomView addSubview:callBtn];
    [callBtn setImage:[UIImage imageNamed:@"icon_home_serviceCall"] forState:UIControlStateNormal];
    [callBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(bottomView.mas_centerX);
        make.top.mas_equalTo(NdgzxmdesLabelTTSqri.mas_bottom).offset(FitRealValue(40));
        make.width.height.mas_equalTo(FitRealValue(110));
    }];
    weakify(self);
    [callBtn bk_addEventHandler:^(id sender) {
        dispatch_async(dispatch_get_main_queue(), ^{
            strongify(self);
            NSString *callStr = [NSString stringWithFormat:@"tel:%@", self.JityuBserviceModelPgophx.kefuPhone];;
            UIWebView *callWebview = [[UIWebView alloc] init];
            [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:callStr]]];
            [self.view addSubview:callWebview];
        });
    } forControlEvents:UIControlEventTouchUpInside];
    
    UILabel *callTipsLabel = [[UILabel alloc] init];
    callTipsLabel.text = @"电话客服";
    callTipsLabel.textAlignment = NSTextAlignmentCenter;
    callTipsLabel.font = FONT(15);
    callTipsLabel.textColor = [UIColor colorWithHexString:@"EE9846"];
    [bottomView addSubview:callTipsLabel];
    [callTipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(bottomView);
        make.left.right.mas_equalTo(bottomView);
        make.top.mas_equalTo(callBtn.mas_bottom).offset(FitRealValue(15));
    }];
    
}

- (void)loadData {
    [IpxzlFJLCFHomeRequestPfjhYJ postServiceWithParams:nil loadingInView:self.view success:^(cwcQCAJLCFHomeServiceDataModelQnsgio *service) {
        self.JityuBserviceModelPgophx = service;
        [self configViews:service];
    } failure:^(NSString *error) {
        [self showNotice:error];
    }];
    
}

- (void)configViews:(cwcQCAJLCFHomeServiceDataModelQnsgio *)service {
    _DrpOoTserviceTimeLabelJpcEbP.text = [NSString stringWithFormat:@"人工客服时间：%@", service.workday?:@""];
    _uSRgyWservicePhoneLabelqKiweC.text = [NSString stringWithFormat:@"客服电话号码：%@", service.kefuPhone?:@""];
}

@end
